<?php
session_start();

$adminEmail=$_SESSION['admin_email'];

unset($_SESSION['admin_email']);
unset($_SESSION['admin_name']);

$log = [
    'action' =>'admin_logout',
    'message' =>'退出后台成功',
    'date_time' =>date('Y-m-d H:i:s',time()),
    'ip' =>$_SERVER['REMOTE_ADDR'],
    'admin_email' =>$adminEmail,
];

$file = fopen("./logs/" . date("Y-m-d") . ".txt", 'a+');
if ($file) {
    fwrite($file, json_encode($log, JSON_UNESCAPED_UNICODE) . PHP_EOL);
    fclose($file);
} else {
    echo "打开文件错误";
    exit();
}

